package com.qianfeng.controller;

import com.qianfeng.entity.Patient;
import com.qianfeng.entity.PatientSta;
import com.qianfeng.entity.ProSta;
import com.qianfeng.service.PatientService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/PatientController")
public class PatientController {

    @Resource
    PatientService patientService;

    // 返回EChart绘图所需的数据
    @GetMapping("/getByCity/{city}")
    public List<ProSta> getCity(@PathVariable("city") String city){
        return patientService.queryProStaByCity(city + "市");
    }

    // 返回EChart绘图所需的数据
    @GetMapping("/getByProvince/{province}")
    public List<ProSta> getProvince(@PathVariable("province") String province){
        return patientService.queryProStaByProvince(province + "省");
    }

    /**
     * 返回地图页面想要的数据（中国）
     * @return
     */
    @RequestMapping("/getProSta")
    public List<ProSta> getProSta(){
        return patientService.queryProSta();
    }

    // 返回表格页面所需的数据
    @RequestMapping("/getPatientinfo")
    public List<Patient> getPatientinfo(@RequestParam("city") String city){
        return patientService.queryPatient(city + "市");
    }

    //// 返回表格页面所需的数据
    @RequestMapping("/getProvincePatientinfo")
    public List<Patient> getProvincePatientinfo(@RequestParam("province") String province){
        return patientService.queryProvincePatient(province + "省");
    }


    /**
     * 获取数量
     * @param city
     * @return
     */
    @RequestMapping("/getCount/{city}")
    public Map<String, Integer> getCount(@PathVariable("city") String city){
        return patientService.getCount(city + "市");
    }

    @RequestMapping("/getProvincCount/{province}")
    public Map<String, Integer> getProvinceCount(@PathVariable("province") String province){
        return patientService.getProvinceCount(province + "省");
    }


    @RequestMapping("/getPatient/{id}")
    public Patient getPatientById(@PathVariable("id") Integer id) {
        return patientService.getPatientById(id);
    }

    @RequestMapping("/savePatientPage")
    @ResponseBody
    public String savePatientPage(@RequestParam("id") Integer id) {
        return "addUserInfo";
    }

}
